﻿@page "/xlsio/sparklines"
@inject Microsoft.JSInterop.IJSRuntime JS
@inject Microsoft.AspNetCore.Hosting.IWebHostEnvironment hostingEnvironment
@using System.IO;

@using Syncfusion.Blazor.Buttons
@*Hidden:Lines*@

@using BlazorDemos.Data.FileFormats.XlsIO

@*End:Hidden*@
@inherits SampleBaseComponent;

<SampleDescription>
    <p>This sample demonstrates how to create sparkline charts using XlsIO.</p>
</SampleDescription>
<ActionDescription>
<p>Sparkline is a small chart in a worksheet cell that provides visual representation of data. Essential XlsIO has the APIs for creating and manipulating sparklines.</p>
<p style='display: block'><b>Features:</b></p>
<ul>
<li>Creation of Sparkline types</li>
<li>Sparkline creation from values fetched from a template document</li>
</ul>
</ActionDescription>

<div class="control-section">
    <p style="font-weight:normal">Click the button to view an Excel spreadsheet generated by Essential XlsIO. Please note that Microsoft Excel Viewer or Microsoft Excel is required to view the resultant document.</p>

    <div class="button-section">
        <div id="button-control">
            <div class="row">
                <div>
                    <SfButton @onclick="SparklinesXlsIO">Create Document</SfButton>
                </div>
            </div>
        </div>
    </div>
</div>

<style>
    .control-section .row {
        margin: 10px 0;
    }
</style>

@code {
    MemoryStream excelStream;

    /// <summary>
    /// Create and download the Excel document with sparklines
    /// </summary>
    public async Task SparklinesXlsIO()
    {
        SparklinesService service = new SparklinesService(hostingEnvironment);
        excelStream = service.SparklinesXlsIO();
        await JS.SaveAs("Sample.xlsx", excelStream.ToArray());
    }
}